//
// Created by Administrator on 2024/5/11.
//

#ifndef NATIVELIBS_ENCODERMEDIACODEC_H
#define NATIVELIBS_ENCODERMEDIACODEC_H


extern "C" {
#include <stdint.h>
#include "libavcodec/avcodec.h"
#include "libavutil/frame.h"
#include "libavutil/imgutils.h"
#include "../../yuvlib/source/LibYUVConvert.h"
#include "libavformat/avformat.h"
#include "libavutil/opt.h"

#define LOGE_LOGNative_TAG "EncoderMediaCodec"
#define LOGNative(...) __android_log_print(ANDROID_LOG_DEBUG,LOGE_LOGNative_TAG,__VA_ARGS__)
}

class EncoderMediaCodec {
public:
    int init(int videoWidth, int videoHeight, int bitRate, jbyte fps, int gouSize);

    int init2();

    int encoderOneFrame(uint8_t *inBuff, uint8_t *outBuff);

    void destroy();

private:
    LibYUVConvert *yuvConvert;
    int width;
    int height;
    const AVCodec *avCodec;
    AVCodecContext *avCodecContext;
    AVPacket *avPacket;
    AVFrame *avFrame;
    u_int8_t *outData;
    u_int8_t *i420_v;
    u_int8_t *i420_u;
};


#endif //NATIVELIBS_ENCODERMEDIACODEC_H
